<script setup lang="ts">
import {User, Lock} from '@element-plus/icons-vue'
import useLogin from '@/hook/useLogin.ts'

const {loginForm, loginFormRef, rulesLoginForm, loginSubmit, isLoading} = useLogin()

</script>

<template>
  <div class="login_container">
    <el-row>
      <el-col :span="14" :xs="0"></el-col>
      <el-col :span="10" :xs="24">
        <el-form class="login_form" :model="loginForm" :rules="rulesLoginForm" ref="loginFormRef">
          <h1>Hello</h1>
          <h2>欢迎来到私密空间</h2>
          <el-form-item prop="loginName">
            <el-input :prefix-icon="User" v-model="loginForm.loginName"
                      @keyup.enter="loginSubmit(loginFormRef)"></el-input>
          </el-form-item>
          <el-form-item prop="userPassword">
            <el-input type="password" :prefix-icon="Lock" v-model="loginForm.userPassword" show-password
                      @keyup.enter="loginSubmit(loginFormRef)"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="success" class="login_btn" @click="loginSubmit(loginFormRef)" :loading="isLoading">登录
            </el-button>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
  </div>
</template>

<style scoped lang="scss">
.login_container {
  width: 100%;
  height: 100vh;
  background: url('@/assets/images/background.jpg') no-repeat;
  background-size: cover;
}

.login_form {
  position: relative;
  width: 70%;
  top: 30vh;
  background: url("@/assets/images/login_form.png") no-repeat;
  background-size: cover;
  padding: 40px;

  h1 {
    color: white;
    font-size: 40px;
  }

  h2 {
    font-size: 20px;
    color: white;
    margin: 20px 0;
  }

  .login_btn {
    width: 100%;
  }
}
</style>